package cn.yunhe.service.impl;

import cn.yunhe.api.IMerchantService;
import cn.yunhe.common.TestException;
import cn.yunhe.dto.DateAndTotal;
import cn.yunhe.dto.TotalMsgDto;
import cn.yunhe.mapper.PayOrderMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class MerchantServiceImpl implements IMerchantService {


    @Autowired
    PayOrderMapper payOrderMapper;

    /**
     * 查询今天
     * @param merchantId
     * @return
     * @throws TestException
     */
    @Override
    public TotalMsgDto queryTodayTotalByMerchantId(Long merchantId) throws TestException {
        //非空校验
        if (merchantId == null){
            throw new TestException("2000","参数为空");
        }


        TotalMsgDto totalMsgDto = payOrderMapper.queryTodayTotal(merchantId);

        return totalMsgDto;
    }


    /**
     * 查询昨天
     * @param merchantId
     * @return
     * @throws TestException
     */
    @Override
    public TotalMsgDto queryYesterdayTotalByMerchantId(Long merchantId) throws TestException {
        //非空校验
        if (merchantId == null){
            throw new TestException("2000","参数为空");
        }


        TotalMsgDto totalMsgDto = payOrderMapper.queryYesterdayTotal(merchantId);

        return totalMsgDto;
    }

    @Override
    public List<DateAndTotal> queryDoubleWeek(Long merchantId) throws TestException {
        //非空校验
        if (merchantId == null){
            throw new TestException("2000","参数为空");
        }

        List<DateAndTotal> list = payOrderMapper.queryDoubleWeek(merchantId);
        return list;
    }
}
